import unittest
from calculator import Count


class TestCaculator(unittest.TestCase):
    def setUp(self):
        print('Start')

    @unittest.skip('强制跳过')
    def testAdd1(self):
        self.cal = Count(2, 3)
        self.assertEqual(self.cal.add(), 5)

    @unittest.skipIf(10 > 2, '满足条件则跳过')
    def testDiv(self):
        self.cal = Count(20, 2)
        self.assertEqual(self.cal.div(), 10)

    @unittest.skipUnless(10 > 12, '不满足条件则跳过')
    def testMul(self):
        self.cal = Count(2, 3)
        self.assertEqual(self.cal.mul(), 2)

    # @unittestdemo.expectedFailure
    def testSub(self):
        self.cal = Count(10, 2)
        self.assertEqual(self.cal.sub(), 15)

    def tearDown(self):
        print('End')


if __name__ == '__main__':
    # unittestdemo.main()
    # TestCaculator('testAdd1').run()
    suite = unittest.TestSuite()
    suite.addTests(
        (TestCaculator('testAdd1'), TestCaculator('testDiv'), TestCaculator('testMul'), TestCaculator('testSub')))
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
